XML = Class.create();

XML.MODULE = "Microsoft.XMLDOM";

XML.getInstance = function(_rootName) {

	return new XML("<" + _rootName + "/>");

}

XML.construct = function($self, $class) {

	var $xmlDoc;

	var $path = "";

	this.initialize = function(rootNode_or_filePath) {

		$xmlDoc = new ActiveXObject(XML.MODULE);

		$xmlDoc.async = false;

		rootNode_or_filePath = rootNode_or_filePath.replace(/\<\?.+\?\>/, "");

		$xmlDoc.loadXML("<?xml version = \"1.0\" encoding= \"GB2312\"?>"
				+ rootNode_or_filePath);
	}

	this.newNode = function(_nodeName) {

		return new Node($xmlDoc.createElement(_nodeName));

	}

	this.getRoot = function() {

		return new Node($xmlDoc.documentElement);

	}

	this.selectSingleNode = function(_pattern) {

		if ($xmlDoc.selectSingleNode(_pattern) == null)

			return null;

		else

			return new Node($xmlDoc.selectSingleNode(_pattern));

	}

	this.selectNodeSet = function(_pattern) {

		var _nodes = $xmlDoc.selectNodes(_pattern);

		if (_nodes.length == 0)

			return null;

		var _arrayNodes = new Array();

		for (var _i = 0; _i < _nodes.length; _i++) {

			_arrayNodes.push(new Node(_nodes[_i]));

		}

		return _arrayNodes;

	}

	this.getValue = function() {

		return $xmlDoc;

	}

	this.getXML = function() {

		return $xmlDoc.documentElement.xml;

	}
}

Node = Class.create();

Node.construct = function($self, $class) {

	var $node = "";

	this.initialize = function(_node) {

		$node = _node;

	}

	this.pushNewNode = function(_name, _value) {

		var _xml = $node.ownerDocument;

		var _node = new Node(_xml.createElement(_name));

		if (_value != null)

			_node.setText(_value);

		$node.appendChild(_node.getValue());

		return _node;

	}

	this.getNodeCount = function() {

		return $node.childNodes.length;

	}

	this.getNodeSet = function() {

		var _childSet = new Array();

		for (var _i = 0; _i < this.getNodeCount(); _i++) {

			_childSet.push(new Node($node.childNodes[_i]));

		}

		return _childSet;

	}

	this.getParentNode = function() {

		try {

			return new Node($node.parentNode);

		} catch (_err) {

			return null;

		}

	}

	this.setAttribute = function(_attrName, _attrValue) {

		$node.setAttribute(_attrName, _attrValue);

	}

	this.getAttributeSet = function() {

		var _attrs = Array();

		for (var _i = 0; _i < $node.attributes.length; _i++) {

			_attrs.push(new Attribute($node.attributes[_i].name,
					$node.attributes[_i].value));

		}

		return _attrs;

	}

	this.getAttribute = function(_attrName) {

		return $node.getAttribute(_attrName);
	}

	this.removeAttribute = function(_attrName) {

		$node.removeAttribute(_attrName);

	}

	this.pushNode = function(_node) {

		$node.appendChild(_node.getValue());

	}

	this.getXML = function() {

		return $node.xml;

	}

	this.removeNode = function(_node) {

		$node.removeChild(_node.getValue());
	}

	this.removeAllNode = function() {

		var _childs = $node.childNodes;

		while (_childs.length != 0) {

			$node.removeChild(_childs[0]);

		}

	}

	this.getValue = function() {

		return $node;

	}

	this.getName = function() {

		return $node.nodeName;

	}

	this.equal = function(_node) {

		if ($self.super0.equal(_node))

			return this.getName() == _node.getName();

		return false;

	}

	this.getText = function() {

		return $node.text;

	}

	this.setText = function(_text) {

		$node.appendChild($node.ownerDocument.createCDATASection(_text));

	}

	this.clone = function() {

		return new Node($node.cloneNode(true));

	}

	this.selectSingleNode = function(_pattern) {

		if ($node.selectSingleNode(_pattern) == null)

			return null;

		else

			return new Node($node.selectSingleNode(_pattern));

	}

	this.selectNodeSet = function(_pattern) {

		var _nodes = $node.selectNodes(_pattern);

		if (_nodes.length == 0)

			return $null();

		var _arrayNodes = new Array();

		for (var _i = 0; _i < _nodes.length; _i++) {

			_arrayNodes.push(new Node(_nodes[_i]));

		}

		return $ary(_arrayNodes);

	}
}

/** ********************************************************************************************************************* */

Attribute = Class.create();

Attribute.construct = function($self, $class) {

	var $name = "";

	var $value = "";

	this.initialize = function(_name, _value) {

		$name = _name;

		$value = _value;
	}

	this.getName = function() {

		return $name;

	}
}
/** ***************************************************************************************************************************** */
Page = Class.create();

Page.ROOTPATH = "";

Page.PE = null;

Page.configRootPath = function(_floor) {

	for (var _i = 0; _i < _floor; _i++)

		Page.ROOTPATH += "../";

}

Page.getInstance = function() {

	return Page.PE == null
			? (Page.PE = new Page(Page.ROOTPATH), Page.PE)
			: Page.PE;
}

Page.construct = function() {

	this.initialize = function(_rootPath) {

		$rootPath = _rootPath;

		Ext.QuickTips.init();

		Ext.BLANK_IMAGE_URL = Page.ROOTPATH + "images/s.gif";
	}

	this.getAction = function(_namespace) {

		var _action = Page.ROOTPATH + "server/interface/"
				+ _namespace.replace(/\./g, "/");

		_action = _action + ".asp";

		return _action;

	}

}

/** **************************************************************************************************************************** */

Message = Class.create();

Message.getInstance = function() {

	return new Message();

}

Message.construct = function($self, $class) {

	var $xml = null;

	this.initialize = function() {

		$xml = XML.getInstance("message");

	}

	this.getVariable = function(_name) {

		var _node = $xml.getRoot().selectSingleNode("//variable[@name = '"
				+ _name + "']");

		if (_node == null)

			return null;

		return _node.getText();

	}

	this.setVariable = function(_name, _value) {

		var _node = $xml.getRoot().selectSingleNode("//variable[@name = '"
				+ _name + "']");

		if (_node == null)

			var _node = $xml.getRoot().pushNewNode("variable", _value);

		_node.setAttribute("name", _name);
	}

	this.getXML = function() {

		return $xml.getXML();
	}
}